//
//  JianLiDetViewController.m
//  YaDiuDiu
//
//  Created by 欧洪飞 on 2017/8/24.
//  Copyright © 2017年 jy. All rights reserved.
//

#import "JianLiDetViewController.h"

#import "JLDetView.h"
#import "JLTwoCell.h"
#import "JLThreeCell.h"
@interface JianLiDetViewController ()<UITableViewDelegate,UITableViewDataSource>{
    
}

@property (nonatomic,strong)UITableView *tableView;

@end

@implementation JianLiDetViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setBGColor];
    
    [self showNav:@"简历详情"];
    [self loadUI];
    NSLog(@"dic:%@",_dic);
    
}

- (void)loadUI{
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, ScreenWidth, ScreenHeight-64) style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [self.view addSubview:_tableView];
    
    JLDetView *detView = [[[NSBundle mainBundle] loadNibNamed:@"JLDetView" owner:nil options:nil] lastObject];
    detView.frame = CGRectMake(0, 0, ScreenWidth, 400);
    _tableView.tableHeaderView = detView;
    
    detView.labName.text = [_dic objectForKey:@"realname"];
    NSString *gender = [NSString stringWithFormat:@"%li",[[_dic objectForKey:@"gender"] integerValue]];
    if ([gender integerValue] == 2) {
       detView.labSex.text = @"男";
    }else{
        detView.labSex.text = @"女";
    }
    NSString *ismarriage = [NSString stringWithFormat:@"%li",[[_dic objectForKey:@"ismarriage"] integerValue]];
    if ([ismarriage integerValue] == 2) {
        detView.labHY.text = @"未婚";
    }else{
        detView.labHY.text = @"已婚";
    }
    detView.labJG.text = [_dic objectForKey:@"nativeplace"];
    detView.labZY.text = [_dic objectForKey:@"workname"];
    detView.labNX.text = [_dic objectForKey:@"yearmoney"];
    NSString *quit = [NSString stringWithFormat:@"%li",[[_dic objectForKey:@"quit"] integerValue]];
    if ([quit integerValue] == 2) {
        detView.labLZDate.text = @"离职";
    }else{
        detView.labLZDate.text = @"在职";
    }
    detView.labPhone.text = [NSString stringWithFormat:@"%li",[[_dic objectForKey:@"phone"] integerValue]];
    detView.labIDCard.text = [_dic objectForKey:@"idcardno"];
    detView.labZJ.text = [_dic objectForKey:@"idcardadd"];
    detView.labXJD.text = [_dic objectForKey:@"permanentadd"];
    detView.labXL.text = [_dic objectForKey:@"education"];
    detView.labZY.text = [_dic objectForKey:@"major"];
    detView.labSchool.text = [_dic objectForKey:@"school"];
    detView.labJJPerson.text = [NSString stringWithFormat:@"紧急联系人(%@)：",[_dic objectForKey:@"emergencyrelation"]];
    detView.labJJPhone.text = [NSString stringWithFormat:@"%li",[[_dic objectForKey:@"emergency"] integerValue]];
    NSArray *arr = [_dic objectForKey:@"comment"];
    for (NSDictionary *dics in arr) {
        NSLog(@"companyname:%@",[dics objectForKey:@"companyname"]);
        NSLog(@"content:%@",[dics objectForKey:@"content"]);
    }
    
}
#pragma -mark UITableViewDelegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}
#pragma -mark UITableViewDataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        return _array.count;
    }
    return 1;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        static NSString *cellId = @"Cell1";
        JLTwoCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
        if (!cell) {
            cell = [[[NSBundle mainBundle] loadNibNamed:@"JLTwoCell" owner:nil options:nil] lastObject];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        NSDictionary *dic = _array[indexPath.row];
        cell.labCompany.text = [dic objectForKey:@"companyname"];
        cell.labPlace.text = [dic objectForKey:@"companyaddress"];
        cell.labJod.text = [dic objectForKey:@"position"];
        cell.labMoney.text = [dic objectForKey:@"salary"];
        cell.labWorkDate.text = [NSString stringWithFormat:@"%@-%@",[dic objectForKey:@"starttime"],[dic objectForKey:@"endtime"]];
        cell.labLZReson.text = [dic objectForKey:@"reason"];
        cell.labPJ.text = [dic objectForKey:@"evaluate"];
        
        
        
        return cell;
    }else{
        
        static NSString *cellId = @"Cell2";
        JLThreeCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
        if (!cell) {
            cell = [[[NSBundle mainBundle] loadNibNamed:@"JLThreeCell" owner:nil options:nil] lastObject];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        NSDictionary *dic = _datas[indexPath.row];
        cell.labSchool.text = [dic objectForKey:@"organization"];
        cell.labZY.text = [dic objectForKey:@"major"];
        cell.labStartDate.text = [dic objectForKey:@"starttime"];
        cell.labEndDate.text = [dic objectForKey:@"endtime"];
        
        return cell;
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        return 160.0;
    }
    return 110.0;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 40.0)];
    view.backgroundColor = [UIColor whiteColor];
    
    UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(16, 13, 80, 14)];
    lab.text = @"工作经历";
    lab.font = [UIFont systemFontOfSize:15.0];
    [view addSubview:lab];
    
    if (section == 1) {
        lab.text = @"教育经历";
    }
    
    return view;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 40;
}

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 40.0)];
    view.backgroundColor = [UIColor whiteColor];
    
    UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(16, 13, 80, 14)];
    lab.text = @"教育经历";
    lab.font = [UIFont systemFontOfSize:15.0];
    [view addSubview:lab];
    
    return view;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
